<?php
require_once(dirname(__FILE__)."/config.php");

if(empty($pid)) $pid='';				
if(empty($sid)) exit();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sites</title>
<link href="../css/admin.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery-1.5.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
	$(function () {
		$('.commonTable tr').hover(function () {
			$(this).css('background-color', '#ffffae');
		},
        function () {
        	$(this).css('background-color', '#FFFFFF');
        });
       });
	function addcol()
	{
		window.location = "add_col.php?sid=<?php echo($sid);?>&pid=<?php echo($pid);?>";
	}
	function editcol(cid)
	{
		window.location = "add_col.php?sid=<?php echo($sid);?>&pid=<?php echo($pid);?>&cid=" + cid;
	}
	function delcol(cid)
	{
		if(confirm('确定删除？'))
			window.location = "columns.php?sid=<?php echo($sid);?>&pid=<?php echo($pid);?>&del=" + cid;
	}
	function viewchild(cid)
	{
		window.location = "columns.php?sid=<?php echo($sid);?>&pid=" + cid;
	}
</script>
</head>
<body>
	<?php 
		$curName="";
		$ppid="";			
		if(!empty($pid))
		{
			$sql = "select * from `#@__column` where cid='$pid'";
			$dsql->SetQuery($sql);				
			$row = $dsql->GetOne();
			if(isset($row))
			{
				$curName = $row["cname"];
				$ppid = $row["parentid"];
			}
		}
		else if(!empty($sid))
		{
			$sql = "select * from `#@__site` where sid='$sid'";
			$dsql->SetQuery($sql);				
			$row = $dsql->GetOne();
			if(isset($row))
				$curName = $row["sname"];
		}
	?>
	<div style=" width:80px; float:right;"><a href="columns.php?sid=<?php echo($sid);?>&pid=<?php echo($ppid);?>" > << 返回上级</a></div>
	<div class="listTitle">当前栏目:<?php echo($curName);?>
		</div>
	<div class="btnDiv"><input type="button" value="添加子栏目" onclick="addcol()" />&nbsp;&nbsp;<input type="button" value="排序" onclick="sortSite()" /></div>
	<div><table class="commonTable" width="100%" cellspacing="0" cellpadding="5" >
	    <tr>
		    <th>名称</th>
			<th>类型</th>
			<th>模板</th>
			<th>状态</th>
		    <th width="60" >
		    </th>
	    </tr>
		<?php
			if(!empty($del))
			{
				$dsql->SetQuery("delete from `#@__column` where cid='$del'");
				$dsql->Execute();//->ExecNoneQuery($del);
			}
			$query = "select * from `#@__column` where parentid='$pid' and sid='$sid' and disabled='0' order by sortno";
			$dsql->SetQuery($query);
			$dsql->Execute();
			while ($row = $dsql->GetArray())
			{?>
			<tr>
			<td><a href="javascript:viewchild('<?=$row['cid']?>')"><?=$row['cname']?></a></td>
			<td><?=$row['ctype']?></td>
			<td><?=$row['templateid']?></td>
			<td><?=$row['display']==0?"显示":"隐藏"?></td>
			<td><a href="javascript:editcol('<?=$row['cid']?>')">编辑</a>&nbsp;<a href="javascript:delcol('<?=$row['cid']?>') ">删除</a></td>
			</tr>
		<?php
			}
		?>
	</table></div>
</body>
</html>